
<table class="box-vang5" cellpadding="0" cellspacing="0" width="100%">
        <tbody><tr class="light">
          <td class="text-top">.:. Cơ hội bán hàng</td>
        </tr>
      </tbody></table>
      <table class="box-vang5" cellpadding="0" cellspacing="0" width="100%">
        <tbody><tr class="light"> 
          <td class="t-l"></td>
          <td class="t-c"></td>
          <td class="t-r"></td>
        </tr>
        <tr class="light">
          <td class="c-l"></td>
          <td class="c-c" valign="top">
  <form action="" method="post">

     <p>
    &nbsp;&nbsp;
    <span>Tên khách hàng</span> 
    <span> 
    	<input type="text" style="width:200px;" name="TenKh"/>
    </span> 
    &nbsp;
    <span>loại khách hàng </span>
    <span> 
    	<select name="loaiKh"> 
        	<option value="">--Lựa chọn--</option>
            <option value="1">Cá nhân</option>
            <option value="2">Tổ chức</option>
        </select>
    </span>
    &nbsp;
    <span>Đơn vị quản lý </span>
    <span> 
    	<select name="DonViQl"> 
        	<option value="">--Lựa chọn--</option>
        <?php $sql_dv=mysql_query("select room_id,room_name from tb_room");
			while($rs_dv=mysql_fetch_array($sql_dv))
			{
		?>    
            <option value="<?php echo $rs_dv['room_id'];?>"><?php echo $rs_dv['room_name'];?></option>
        <?php }?>   
        </select>
    </span>
    <span><input name="button" type="submit" value="Tìm kiếm" class="cs-title-timkiem"/></span>
    &nbsp;&nbsp;</p>
    
 </form>
    <div class="clear" style="height:10px"></div>
<?php 
	$search=$_POST['TenKh'];
	$loaiKh=$_POST['loaiKh'];
	$DonViQl=$_POST['DonViQl'];
?>
<?php 

	$sqlstring="select  
						cohoi.id,
						cohoi.name,
						cohoi.kh_id,
						cohoi.product_id,
						cohoi.doanhthu,
						cohoi.manager,
						trangthai
					from 
						cohoi
						
					";

	
	$qr1=mysql_query($sqlstring); 
	$i=0;
  ?>
<table id="box-quick" class="box-quick" border="0" cellpadding="5" cellspacing="0" width="100%">
          <tbody><tr id="title">
            <td width="2%">STT</td>
            <td width="15%">Tên cơ hội</td>
            <td width="15%">Tên khách hàng</td>
            <td width="10%">người quản lý</td>
            <td width="10%">Sản phẩm</td>
            <td width="10%">Doanh thu</td>
            <td width="10%">Trạng thái</td>
            <td width="6%">Thao tác</td>
          </tr>
         <?php 
		 	while($row=mysql_fetch_array($qr1)) 
			{
				$i=$i+1;
							
		 ?>
           <tr class="light" id="value" style="cursor:pointer;" onmouseover="mouse_den(this)" onmouseout="mouse_di(this)" bgcolor="">
            <td style="border-left:1px solid #ccc"><div align="center"><?php echo $i;?></div></td>
            <td  class="tdbg_2"><div align="left">&nbsp;<span title="">
				<a href="index.php?tn=customers&kh=cohoi_detail&id=<?php echo $row['id'];?>"><?php echo $row['name'];?></a>
                 </span>
                </div>
            </td>
           
            <td>
				 <?php $sql_kh=mysql_query("select id,name_kh,name_com from customers where id='".$row['kh_id']."'");
				while($row_kh=mysql_fetch_array($sql_kh))
				{
			?>
			<?php echo $row_kh['name_com']; echo $row_kh['name_kh'];
				}
			?>
             </td>
           <td align="center"> 
           	<?php 
						$sql_ql=mysql_query("select account_id,account_name from tb_account_admin where account_id='".$row['manager']."'");
						while($rs_ql=mysql_fetch_array($sql_ql))
						{
							echo $rs_ql['account_name'];
						}
					?>
           </td>
             <td>
             	 <?php 
					  	$product_id=explode(',',$row['product_id']);
						$so_product=count($product_id)-1;
						for($p=1;$p<=$so_product;$p++)
						{
							$tong_product=$product_id[$p-1];
						
							$sql_pr=mysql_query("select IDproduct,Namepro from tb_product where IDproduct='$tong_product'");
							while($rs_pr=mysql_fetch_array($sql_pr))
							{
								echo $rs_pr['Namepro'].',';
							}
						}
					  ?>
             </td>
            <td align="center">
					<?php 
						echo $row['doanhthu'];
					?>
            </td>
            <td align="center" style="color:#f00"> 
            	<?php if($row['trangthai']==1){echo 'Thành công';}?>
                <?php if($row['trangthai']==2){echo 'Đang đàm phán';}?>
                <?php if($row['trangthai']==3){echo 'Thất bại';}?>
            </td>
             
             <td align="center">          	
				<a onmouseout="menuLayers.hide();" onclick="menuLayers.show('<?php echo $row['id'];?>_action_kh', event); "><img width="16" align="absmiddle" src="../skins/images/Thao_Tac_list.png"></a>
													
			
													
                &nbsp;
                            
             </td>
          </tr>
        <div id="<?php echo $row['id'];?>_action_kh" class="layermask" style="left: 1008px; top: 112px; visibility: hidden;">
	<ul>
        <li onclick="window.location='index.php?tn=customers&kh=cohoi_edit&id=<?php echo $row['id'];?>';" style="cursor:pointer;"><img src="../skins/images/edit.png" style="float: left"> <p>Sửa</p>
        </li>
        <li onclick="if(confirm('Bạn muốn xóa cơ hội này không?')){window.location='index.php?tn=customers&kh=cohoi_del&id=<?php echo $row['id'];?>';}" style="cursor:pointer;">
        <img src="../skins/images/del.png" style="float: left"> <p>Xóa</p>
        </li>
         
        
	</ul>				
</div>  

         <?php }?>
         
          
        </tbody>
	</table>

<div id="3_action_kh_view" class="layermask" style="left: 1053px; top: 190px; visibility: hidden;">													
<ul>
		<li onclick="javascript:window.location='http://tamnguyen.gencrm.com/modules/customers/edit?&amp;view=1&amp;p=3&amp;tab=3'" style="cursor:pointer;"><img src="http://tamnguyen.gencrm.com/images/icons/danh-sach.gif" style="float: left"> <p>Đầu mối liên lạc&nbsp; (1)</p>
	</li>
		<li onclick="javascript:window.location='http://tamnguyen.gencrm.com/modules/customers/edit?&amp;view=1&amp;p=3&amp;tab=4'" style="cursor:pointer;"><img src="http://tamnguyen.gencrm.com/images/icons/danh-sach.gif" style="float: left"> <p>Cơ hội bán hàng&nbsp; (0)</p>
	</li>
	<li onclick="javascript:window.location='http://tamnguyen.gencrm.com/modules/customers/edit?&amp;view=1&amp;p=3&amp;tab=5'" style="cursor:pointer;"><img src="http://tamnguyen.gencrm.com/images/icons/danh-sach.gif" style="float: left"> <p>Hợp đồng&nbsp; (0)</p>
	</li>
	<li onclick="javascript:window.location='http://tamnguyen.gencrm.com/modules/customers/edit?&amp;view=1&amp;p=3&amp;tab=6'" style="cursor:pointer;"><img src="http://tamnguyen.gencrm.com/images/icons/danh-sach.gif" style="float: left"> <p>Công việc&nbsp; (0)</p>
</li></ul>												
</div>
      
        </td>
      
      
 <td class="c-r"></td>
        </tr>
        <tr class="light">
          <td class="b-l"></td>
          <td class="b-c"></td>
          <td class="b-r"></td>
        </tr>
      </tbody></table>